import request from '@/utils/request'

export const getEditMenuInfo = (id = -1) => {
  return request({
    method: 'GET',
    url: `/boss/menu/getEditMenuInfo?id=${id}`
  })
}

// 添加菜单接口
export const createOrUpdate = data => {
  return request({
    method: 'POST',
    url: '/boss/menu/saveOrUpdate',
    data
  })
}

// 获取所有菜单
export const getAllMenu = () => {
  return request({
    method: 'GET',
    url: '/boss/menu/getAll'
  })
}

// 删除菜单
export const deleteMenu = (id) => {
  return request({
    method: 'DELETE',
    url: `/boss/menu/${id}`
  })
}

// 获取所有菜单并按照层级显示
export const getMenuNodeList = (id) => {
  return request({
    method: 'GET',
    url: '/boss/menu/getMenuNodeList'
  })
}

// 给角色分配菜单
export const allocateRoleMenus = data => {
  return request({
    url: '/boss/menu/allocateRoleMenus',
    method: 'POST',
    data
  })
}

// 获取角色拥有的菜单列表
export const getRoleMenus = id => {
  return request({
    url: `/boss/menu/getRoleMenus?roleId=${id}`,
    method: 'GET'
  })
}
